package com.example.demo.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.bean.CmsLink;


import com.example.demo.mapper.CmsLinkMapper;


@Service
public class CmsLinkService {
	@Autowired
	private CmsLinkMapper linkMapper;

	public List<CmsLink> getAllLink() {
		List<CmsLink> list=linkMapper.selectAll();
		return list;
	}

	public boolean saveOrUpdateCmsLink(CmsLink link) {
		if(link.getId()!=null) {
			linkMapper.updateByPrimaryKey(link);
			
		}
		else {
			link.setId(UUID.randomUUID().hashCode());//插入的ID
			linkMapper.insert(link);
			
		}
			return true;
	}

	public int deleteById(int id) {
		return linkMapper.deleteByPrimaryKey(id);
	}

}
